package com.soap.service.impl;

import com.soap.entity.query.PersonDto;
import com.soap.feign.service.MSBusinessServiceFeign;
import com.soap.service.PersonSearchService;
import com.soap.utils.HtmlParseUtils;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * Created by ZhangPY on 2021/2/16
 * Belong Organization OVERUN-9299
 * overun9299@163.com
 * Explain: PersonSearchServiceImpl
 */
@Slf4j
@Service
public class PersonSearchServiceImpl implements PersonSearchService {

    @Autowired
    private RestHighLevelClient restHighLevelClient;

    @Autowired
    private HtmlParseUtils htmlParseUtils;

    @Autowired
    private MSBusinessServiceFeign msBusinessServiceFeign;

    @Value("${elasticsearch.personIndices}")
    private String personIndices;


    @Override
    public String getPersons(PersonDto personDto) {
        try {
            SearchRequest java_test = new SearchRequest(personIndices);
            SearchResponse search = restHighLevelClient.search(java_test, RequestOptions.DEFAULT);

            search.getHits();
        } catch (Exception e) {
            log.error(e.getMessage());
        }

        return null;
    }
}
